﻿@model IEnumerable<Article>
@Html.Extra()
@{
    var catalog = ViewBag.Catalog as Catalog;
    var config = SerializationHelper.JsonDeserialize<JObject>(catalog == null ? "" : catalog.Config);
}
<table>
    <thead>
        <tr>
            <th>
                @(string.IsNullOrEmpty(config.GetString("Title_Display")) ? "标题" : config.GetString("Title_Display"))
            </th>
            @if (config.GetBoolean("FullTitle_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("FullTitle_Display")) ? "完整标题" : config.GetString("FullTitle_Display"))
                </th>
            }
            @if (config.GetBoolean("SubTitle_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("SubTitle_Display")) ? "子标题" : config.GetString("SubTitle_Display"))
                </th>
            }
            @if (config.GetBoolean("Keyword_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("Keyword_Display")) ? "关键字" : config.GetString("Keyword_Display"))
                </th>
            }
            @if (config.GetBoolean("Tag_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("Tag_Display")) ? "标签" : config.GetString("Tag_Display"))
                </th>
            }
            @if (config.GetBoolean("Origin_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("Origin_Display")) ? "来源" : config.GetString("Origin_Display"))
                </th>
            }
            @if (config.GetBoolean("Author_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("Author_Display")) ? "作者" : config.GetString("Author_Display"))
                </th>
            }
            @if (config.GetBoolean("ExtField01_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("ExtField01_Display")) ? "扩展字段一" : config.GetString("ExtField01_Display"))
                </th>
            }
            @if (config.GetBoolean("ExtField02_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("ExtField02_Display")) ? "扩展字段二" : config.GetString("ExtField02_Display"))
                </th>
            }
            @if (config.GetBoolean("ExtField03_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("ExtField03_Display")) ? "扩展字段三" : config.GetString("ExtField03_Display"))
                </th>
            }
            @if (config.GetBoolean("ExtField04_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("ExtField04_Display")) ? "扩展字段四" : config.GetString("ExtField04_Display"))
                </th>
            }
            @if (config.GetBoolean("TransferUrl_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("TransferUrl_Display")) ? "转向链接" : config.GetString("TransferUrl_Display"))
                </th>
            }
            @if (config.GetBoolean("TitleImage_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("TitleImage_Display")) ? "标题图片" : config.GetString("TitleImage_Display"))
                </th>
            }
            @if (config.GetBoolean("City_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("City_Display")) ? "城市" : config.GetString("City_Display"))
                </th>
            }
            @if (config.GetBoolean("PublishTime_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("PublishTime_Display")) ? "发布时间" : config.GetString("PublishTime_Display"))
                </th>
            }
            @if (config.GetBoolean("ViewCount_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("ViewCount_Display")) ? "查看数" : config.GetString("ViewCount_Display"))
                </th>
            }
            @if (config.GetBoolean("CommentCount_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("CommentCount_Display")) ? "评论数" : config.GetString("CommentCount_Display"))
                </th>
            }
            @if (config.GetBoolean("IsCommend_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("IsCommend_Display")) ? "推荐" : config.GetString("IsCommend_Display"))
                </th>
            }
            @if (config.GetBoolean("IsHot_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("IsHot_Display")) ? "热门" : config.GetString("IsHot_Display"))
                </th>
            }
            @if (config.GetBoolean("IsTop_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("IsTop_Display")) ? "置顶" : config.GetString("IsTop_Display"))
                </th>
            }
            @if (config.GetBoolean("Summary_ListVisible"))
            {
                <th>
                    @(string.IsNullOrEmpty(config.GetString("Summary_Display")) ? "摘要" : config.GetString("Summary_Display"))
                </th>
            }
            <th>
                创建时间
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr id="@item.Id">
                <td>
                    <span style="@item.TitleStyle">
                        <a href="javascript:parent.activeTab('CMS_Article', '%E5%85%AC%E5%91%8A%E8%AF%A6%E7%BB%86', '/CMS/Article/Detail/@(item.Id)?VPartial=DetailForIndex');">@item.Title</a>
                    </span>
                </td>
                @if (config.GetBoolean("FullTitle_ListVisible"))
                {
                    <td>
                        @item.FullTitle
                    </td>
                }
                @if (config.GetBoolean("SubTitle_ListVisible"))
                {
                    <td>
                        @item.SubTitle
                    </td>
                }
                @if (config.GetBoolean("Keyword_ListVisible"))
                {
                    <td>
                        @item.Keyword
                    </td>
                }
                @if (config.GetBoolean("Tag_ListVisible"))
                {
                    <td>
                        @item.Tag
                    </td>
                }
                @if (config.GetBoolean("Origin_ListVisible"))
                {
                    <td>
                        @item.Origin
                    </td>
                }
                @if (config.GetBoolean("Author_ListVisible"))
                {
                    <td>
                        @item.Author
                    </td>
                }
                @if (config.GetBoolean("ExtField01_ListVisible"))
                {
                    <td>
                        @item.ExtField01
                    </td>
                }
                @if (config.GetBoolean("ExtField02_ListVisible"))
                {
                    <td>
                        @item.ExtField02
                    </td>
                }
                @if (config.GetBoolean("ExtField03_ListVisible"))
                {
                    <td>
                        @item.ExtField03
                    </td>
                }
                @if (config.GetBoolean("ExtField04_ListVisible"))
                {
                    <td>
                        @item.ExtField04
                    </td>
                }
                @if (config.GetBoolean("TransferUrl_ListVisible"))
                {
                    <td>
                        @item.TransferUrl
                    </td>
                }
                @if (config.GetBoolean("TitleImage_ListVisible"))
                {
                    <td>
                        @Html.Show().Image(item.TitleImageUrl, new ImageOptions
                        {
                            AttachmentTypeCode = "CMS_ArticleTitleImage",
                            Width = config.GetInt("TitleImage_Width"),
                            Height = config.GetInt("TitleImage_Height")
                        })
                    </td>
                }
                @if (config.GetBoolean("City_ListVisible"))
                {
                    <td>
                        @item.City
                    </td>
                }
                @if (config.GetBoolean("PublishTime_ListVisible"))
                {
                    <td>
                        @StringHelper.FormatDateAndTime(item.PublishTime)
                    </td>
                }
                @if (config.GetBoolean("ViewCount_ListVisible"))
                {
                    <td>
                        @item.ViewCount
                    </td>
                }
                @if (config.GetBoolean("CommentCount_ListVisible"))
                {
                    <td>
                        @item.CommentCount
                    </td>
                }
                @if (config.GetBoolean("IsCommend_ListVisible"))
                {
                    <td>
                        @Html.Show().CheckBox(item.IsCommend)
                    </td>
                }
                @if (config.GetBoolean("IsHot_ListVisible"))
                {
                    <td>
                        @Html.Show().CheckBox(item.IsHot)
                    </td>
                }
                @if (config.GetBoolean("IsTop_ListVisible"))
                {
                    <td>
                        @Html.Show().CheckBox(item.IsTop)
                    </td>
                }
                @if (config.GetBoolean("Summary_ListVisible"))
                {
                    <td>
                        @item.Summary
                    </td>
                }
                <td>
                    @StringHelper.FormatDateAndTime(item.CreateTime)
                </td>
            </tr>
        }
    </tbody>
</table>
